<template>
	<div class="progress-bar" :style="{ width: containerWidth + 'px'}">
		<div class="progress-bar-link" v-for="n in progressLength"
			:class="{ 'progress-bar-no-right': n === progressLength, 'active': n <= activeNumber }">
			{{ n }}
		</div>
	</div>
</template>

<script>
export default {
  name: 'VProgressBar',
  props: {
    length: {
      type: [Number, String],
      default: 4
    },
    active: {
      type: [Number, String],
      default: 1
    }
  },
  data () {
    return {
    }
  },
  computed: {
    progressLength () {
      return parseInt(this.length)
    },
    activeNumber () {
      return parseInt(this.active)
    },
    containerWidth () {
      return this.progressLength * 200 - 160
    }
  }
}
</script>

<style scoped>
.progress-bar {
	margin: 0 auto;
	overflow: hidden;
}

.progress-bar:after {
	content: '';
	display: block;
	width: 0;
	height: 0;
	visibility: hidden;
	clear: both;
}

.progress-bar-link {
	float: left;
	width: 40px;
	height: 40px;
	background-color: #e7e7e7;
	border-radius: 50%;
	font-size: 18px;
	text-align: center;
	line-height: 40px;
	color: #b2b2b2;
	margin-right: 160px;
	position: relative;
}

.progress-bar-no-right {
	margin-right: 0;
}

.progress-bar-link:before, .progress-bar-link:after {
	content: '';
	display: block;
	width: 80px;
	height: 6px;
	background-color: #e6e6e6;
	position: absolute;
	top: 17px;
}

.progress-bar-link:before {
	left: -80px;
}

.progress-bar-link:after {
	right: -80px;
}

.active {
	color: #fff;
	background-color: #ff600a;
}

.active:before {
	background-color: #ff600a;
}

.active:after {
	background-color: #ff600a;
}
</style>
